#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int E[100001]={0};
int cmp(int a,int b){
	return a>b;
}
int main() {
	int n,sum=0,i;
	cin>>n;
	vector<int> v(n+1);
	for(i=1; i<=n; i++)
		cin>>v[i];
	sort(v.begin()+1,v.end(),cmp);
	for(i=1;i<=n;i++){
		if(i>=v[i]) break;
	}
	cout<<i-1;
	return 0;
}
